iT邦幫忙

0

VS2017 C# connect Oracle9i

  • 分享至 

  • xImage
  •  

工具:VS2017
DB:Oracle9i

oracle为c#提供了2個Driver:Oracle.DataAccess.dll與 Oracle.ManagedDataAccess.dll
(1) Oracle.DataAccess.dll
VS2017->NUGET下載
https://ithelp.ithome.com.tw/upload/images/20191208/20122497xOmw8xozBt.png

https://ithelp.ithome.com.tw/upload/images/20191208/20122497Ns97Kxealz.png

引用using Oracle.DataAccess.Client;
2種連線方式 PS xxx自填
(2.1) Varchar config = @"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1521)))
(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=xxx)));User Id= xxx;Password= xxx;";
//HOST: 是TCP / IP協議使用的伺服器IP地址。
//PORT: 是TCP / IP使用的埠地址。
//CONNECT_DATA: 連線資料庫的連線配置
//SERVER = DEDICATED: (可省略) 表示用專用伺服器連線oracle資料庫
//SERVICE_NAME:伺服器服務名稱
// Oracle 找到tnsnames.ora
// TOPPROD.xxxx.COM.TW =
// (DESCRIPTION =
// (ADDRESS_LIST =
// (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521)))
// (CONNECT_DATA =
// (SERVICE_NAME = xxx)
// )
// )

(2.2) Varchar config = @"Data Source=xxx.xxx.xxx.xxx:1521/xxx;User Id=xxx;Password=xxx;";

(2)Oracle.ManagedDataAccess.dll
連線失敗(失敗內容:ora-01017: invalid username/password; logon denied,跟帳密無關是Oracle.ManagedDataAccess.dll不支援Oracle9i連線),未研究成功
https://ithelp.ithome.com.tw/upload/images/20191208/20122497cnQVhguXIF.png

https://ithelp.ithome.com.tw/upload/images/20191208/20122497b0CbpQSkjN.png

也另外找官網下載Oracle.ManagedDataAccess.dll(版本是ODAC 12c)
另外一篇也講到網站 ODAC 12c支援到Access to Oracle Database 10g Release 2 or later

(3)NET內建OracleClient微軟未來不支援了
https://ithelp.ithome.com.tw/upload/images/20191208/20122497N0aRAYB6mW.png


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言